Understanding Replaced Elements in the CSS Box Model
Replaced elements are HTML elements whose content is not directly controlled by CSS, but by external sources—such as an image file, video, or form control. Examples include <img>, <input>, <video>, <iframe>, and <object>.
While replaced elements still participate in the CSS box model, their intrinsic (natural) size often determines their width and height unless explicitly overridden by CSS. The browser replaces their content with an external resource, which defines part of their rendering behavior.
They generate a box like any other element with content, padding, border, and margin.
Their intrinsic dimensions (like an image's natural width and height) determine their box size if CSS doesn’t override it.
You can set width, height, padding, border, and margin normally — these affect layout as expected.
Their content box corresponds to the replaced content area (e.g., the actual image).
In this example, the image behaves like a block-level box by default, respecting padding, borders, and margins. Its intrinsic image content defines the base box size, which CSS can modify.
Replaced elements don’t have descendant content — their visual content comes from an external source.
Intrinsic ratio and object-fit/object-position can control how their content is displayed within the box.
They can behave as inline, block, or inline-block depending on the element type and CSS display property.